<template>
   <a-col :span="span">
        <formItem v-for="(field,idx) in formfields" :key="idx" :form="form" :changeItem="changeItem" :item="field" :formRef="componentRef" @clickEventHandler="clickEventHandler" @showIconSelect="showIconSelect"></formItem>
    </a-col>
</template>
<script>

import formItem from '@/components/lt/form/LFormItem'
import {findComponentUpward} from '@/utils/util'

export default {
    name:'ExtFormCol',
    components:{formItem},
    props:{
        span:{
            type:Number,
            default:12
        },
        componentRef:[String,Number],
        formfields:{
           type:Array,
           default:()=>[]
        },
        entityClassName:{
            type:String,
            default:'',
            required: false
        },
        
        
    },
    data(){
        return{
            form:{},
            changeItem:{},//表单中当前改变值的组件，键值对
        }
    },
   
    created(){
        this.setEntityClassName()
    },
    methods:{
        clickEventHandler(field,form){
            let gridForm = findComponentUpward(this,'ExtGridForm')
            if(gridForm){
                gridForm.clickEventHandler(field)
            }
        },
        showIconSelect(field){
            let gridForm = findComponentUpward(this,'ExtGridForm')
            if(gridForm){
                gridForm.showIconSelect(field)
            }
          
        },
        setEntityClassName(field){
            let gridForm = findComponentUpward(this,'ExtGridForm')
            if(gridForm){
                this.form = gridForm.form
                gridForm.entityClassName = this.entityClassName
            }
          
        }


    }
}
</script>